package org.snail.attendence.bean;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

import lombok.ToString;
import lombok.extern.log4j.Log4j;
import org.snail.config.CustomDateSerializer;
import org.snail.excel.annotation.ExcelBean;
import org.snail.excel.annotation.ExcelColumn;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * ali工时
 * Created by WJ on 2017/11/13.
 */
@Data
@Log4j
@ToString
@ExcelBean
@Document(collection = "attendenceMongo")
public class AliWorkDTO implements Serializable{

    //姓名
    @ExcelColumn(name = "employeeName", position = 0, columnName = "姓名")
    private String employeeName;

    //部门
    @ExcelColumn(name = "department", position = 1, columnName = "部门")
    private String department;

    //阿里工号
    @Indexed
    @ExcelColumn(name = "aliNumber", position = 2, columnName = "阿里工号")
    private String aliNumber;

    //日期
    @ExcelColumn(name = "dateStr", position = 5, columnName = "日期")
    private String dateStr;

    //班次
    @ExcelColumn(name = "order", position = 6, columnName = "班次")
    private String order;

    //上班1_打卡时间
    @ExcelColumn(name = "punchTime1", position = 7)
    private String punchTime1;

    //上班1_打卡结果
    @ExcelColumn(name = "punchComment1", position = 8)
    private String punchComment1;

    //下班1_打卡时间
    @ExcelColumn(name = "punchTime2", position = 9)
    private String punchTime2;

    //下班1_打卡结果
    @ExcelColumn(name = "punchComment2", position = 10)
    private String punchComment2;

    //上班2_打卡时间
    @ExcelColumn(name = "punchTime3", position = 11)
    private String punchTime3;

    //上班2_打卡结果
    @ExcelColumn(name = "punchComment3", position = 12)
    private String punchComment3;

    //下班2_打卡时间
    @ExcelColumn(name = "punchTime4", position = 13)
    private String punchTime4;

    //下班2_打卡结果
    @ExcelColumn(name = "punchComment4", position = 14)
    private String punchComment4;

    //关联的审批单
    @ExcelColumn(name = "approval", position = 15, columnName = "请假明细")
    private String approval;

    //出勤天数
    @ExcelColumn(name = "attendanceDay", position = 16)
    private String attendanceDay;

    //休息天数
    @ExcelColumn(name = "freeDay", position = 17)
    private String freeDay;

    //工作时长(分钟)
    @ExcelColumn(name = "attendenceMin", position = 18)
    private String attendenceMin;

    //迟到次数
    @ExcelColumn(name = "tardinessCount", position = 19)
    private String tardinessCount;

    //迟到时长(分钟)
    @ExcelColumn(name = "tardinessMin", position = 20)
    private String tardinessMin;

    //严重迟到次数
    @ExcelColumn(name = "criticalTardinessCount", position = 21)
    private String criticalTardinessCount;

    //严重迟到时长(分钟)
    @ExcelColumn(name = "criticalTardinessMin", position = 22)
    private String criticalTardinessMin;

    //旷工迟到天数
    @ExcelColumn(name = "absenteeismAndTardinessDay", position = 23)
    private String absenteeismAndTardinessDay;

    //早退次数
    @ExcelColumn(name = "leaveCount", position = 24)
    private String leaveCount;

    //早退时长(分钟)
    @ExcelColumn(name = "leaveMin", position = 25)
    private String leaveMin;

    //上班缺卡次数
    @ExcelColumn(name = "missingCount", position = 26)
    private String missingCount;

    //下班缺卡次数
    @ExcelColumn(name = "missingCount2", position = 27)
    private String missingCount2;

    //旷工天数
    @ExcelColumn(name = "absenteeismDay", position = 28)
    private String absenteeismDay;

//    //外出(小时）
//    @ExcelColumn(name = "outHour", position = 32)
//    private String outHour;

//    //事假(天)
//    @ExcelColumn(name = "leaveDay", position = 34)
//    private String leaveDay;

    //事假(小时)
    @ExcelColumn(name = "leaveHour", position = 31)
    private String leaveHour;
//
//    //产假(小时)
//    @ExcelColumn(name = "maternityLeaveHour", position = 35)
//    private String maternityLeaveHour;
//
//    //其他(小时)
//    @ExcelColumn(name = "otherLeaveHour", position = 36)
//    private String otherLeaveHour;
//
//    //婚假(小时)
//    @ExcelColumn(name = "marriageLeaveHour", position = 37)
//    private String marriageLeaveHour;
//
//    //年假(天)
//    @ExcelColumn(name = "annualLeaveDay", position = 38)
//    private String annualLeaveDay;
//
//    //年假(小时)
//    @ExcelColumn(name = "annualLeaveHour", position = 39)
//    private  String annualLeaveHour;
//
//    //病假(小时)
//    @ExcelColumn(name = "sickLeaveHour", position = 40)
//    private String sickLeaveHour;

//    //调休(天)
//    @ExcelColumn(name = "overDay", position = 35)
//    private String overDay;

    //调休(小时)
    @ExcelColumn(name = "overHour", position = 32)
    private String overHour;

//    //路途假(小时)
//    @ExcelColumn(name = "journeyHour", position = 43)
//    private String journeyHour;
//
//    //陪产假(小时)
//    @ExcelColumn(name = "paternityLeaveHour", position = 44)
//    private String paternityLeaveHour;
//
//    //加班-审批单统计(小时）
//    @ExcelColumn(name = "overtimeApprovalHour", position = 45)
//    private String overtimeApprovalHour;

    //工作日加班(小时)
    @ExcelColumn(name = "weekdayOverHour", position = 34)
    private String weekdayOverHour;

    //休息日加班(小时)
    @ExcelColumn(name = "weekendOverHour", position = 35)
    private String weekendOverHour;

    //节假日加班(小时)
    @ExcelColumn(name = "festivalOverHour", position = 36)
    private String festivalOverHour;

    /**
     * 下列数据均不是表格中有的数据
     * @param  absentHour --- 缺勤小时数
     */
    @JsonSerialize(using = CustomDateSerializer.class)
    private Date attendenceDate; //日期时间
    private String workNum;     //佰钧成工号
    private Integer empId;
    private List groupIds;      //群组列表的ids
    private Double absentMin;   //缺勤分钟数
    private String groupName ;  //群组名称
    private int isCorrect;     //是否被标记为正常数据
    private int dbstatus;      //是否被标记为正常数据
    private int attId;         //考勤主表id
    private int state;         //做预览 0：不变  1：新增
    private String errReason;  //错误原因
    private Date uploadTime;   //文件上传时间
    private String deptInfo;   //部门信息
    private Date updateTime;
    private int isDel;         //是否删除
    private String du;          //设置DU
    private int rest;    //是否休息 且不加班 0工作日  1休息

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AliWorkDTO)) return false;

        AliWorkDTO that = (AliWorkDTO) o;

        if (getEmployeeName() != null ? !getEmployeeName().equals(that.getEmployeeName()) : that.getEmployeeName() != null)
            return false;
        if (getDepartment() != null ? !getDepartment().equals(that.getDepartment()) : that.getDepartment() != null)
            return false;
        if (getAliNumber() != null ? !getAliNumber().equals(that.getAliNumber()) : that.getAliNumber() != null)
            return false;
        if (getDateStr() != null ? !getDateStr().equals(that.getDateStr()) : that.getDateStr() != null) return false;
        if (getOrder() != null ? !getOrder().equals(that.getOrder()) : that.getOrder() != null) return false;
        if (getPunchTime1() != null ? !getPunchTime1().equals(that.getPunchTime1()) : that.getPunchTime1() != null)
            return false;
        if (getPunchComment1() != null ? !getPunchComment1().equals(that.getPunchComment1()) : that.getPunchComment1() != null)
            return false;
        if (getPunchTime2() != null ? !getPunchTime2().equals(that.getPunchTime2()) : that.getPunchTime2() != null)
            return false;
        if (getPunchComment2() != null ? !getPunchComment2().equals(that.getPunchComment2()) : that.getPunchComment2() != null)
            return false;
        if (getPunchTime3() != null ? !getPunchTime3().equals(that.getPunchTime3()) : that.getPunchTime3() != null)
            return false;
        if (getPunchComment3() != null ? !getPunchComment3().equals(that.getPunchComment3()) : that.getPunchComment3() != null)
            return false;
        if (getPunchTime4() != null ? !getPunchTime4().equals(that.getPunchTime4()) : that.getPunchTime4() != null)
            return false;
        if (getPunchComment4() != null ? !getPunchComment4().equals(that.getPunchComment4()) : that.getPunchComment4() != null)
            return false;
        if (getApproval() != null ? !getApproval().equals(that.getApproval()) : that.getApproval() != null)
            return false;
        if (getAttendanceDay() != null ? !getAttendanceDay().equals(that.getAttendanceDay()) : that.getAttendanceDay() != null)
            return false;
        if (getFreeDay() != null ? !getFreeDay().equals(that.getFreeDay()) : that.getFreeDay() != null) return false;
        if (getAttendenceMin() != null ? !getAttendenceMin().equals(that.getAttendenceMin()) : that.getAttendenceMin() != null)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        int employeeDateHash = 31*dateStr.hashCode() + this.employeeName.hashCode()*31 + this.punchComment1.hashCode()*31
                + this.punchComment2.hashCode()*31 + this.approval.hashCode()*31;    //根据日期+姓名进行判断
        return employeeDateHash;
    }

}
